home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / bin / linux-boot-prober < prev    next >
Text File  |  2009-09-21  |  2KB  |  56 lines

  1. #!/bin/sh
  2. . /usr/share/os-prober/common.sh
  3.  
  4. set -e
  5.  
  6. newns "$@"
  7. require_tmpdir
  8.  
  9. grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true
  10.  
  11. partition="$1"
  12. if ! mapped="$(mapdevfs "$partition")"; then
  13.     log "Device '$partition' does not exist; skipping"
  14.     continue
  15. fi
  16.  
  17. if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map"; then
  18.     for test in /usr/lib/linux-boot-probes/*; do
  19.         debug "running $test"
  20.         if [ -x $test ] && [ -f $test ]; then
  21.             if $test "$partition"; then
  22.                 debug "linux detected by $test"
  23.                 break
  24.             fi
  25.         fi
  26.     done
  27. else
  28.     mpoint=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 2)
  29.     mpoint="$(unescape_mount "$mpoint")"
  30.     if [ "$mpoint" != "/target/boot" ] && [ "$mpoint" != "/target" ] && [ "$mpoint" != "/" ]; then
  31.         type=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 3)
  32.         if ! grep -q " $mpoint/boot " "$OS_PROBER_TMP/mounted-map"; then
  33.             mountboot="$(linux_mount_boot "$partition" "$mpoint")"
  34.             bootpart="${mountboot%% *}"
  35.             bootmounted="${mountboot#* }"
  36.         else
  37.             bootpart="$partition"
  38.             bootmounted=0
  39.         fi
  40.         for test in /usr/lib/linux-boot-probes/mounted/*; do
  41.             if [ -f $test ] && [ -x $test ]; then
  42.                 debug "running $test on mounted $partition"
  43.                 if $test "$partition" "$bootpart" "$mpoint" "$type"; then
  44.                     debug "$test succeeded"
  45.                     break
  46.                 fi
  47.             fi
  48.         done
  49.         if [ "$bootmounted" = 1 ]; then
  50.             if ! umount "$mpoint/boot"; then
  51.                 warn "failed to umount $mpoint/boot"
  52.             fi
  53.         fi
  54.     fi
  55. fi
  56.